<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>goodsUpdate - Swim System</title>
		<link rel="shortcut icon" href="favicon.ico">
		<link href="/swimpool-ssm/back/resources/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
		<link href="/swimpool-ssm/back/resources/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
		<link href="/swimpool-ssm/back/resources/css/animate.min.css" rel="stylesheet">
		<link href="/swimpool-ssm/back/resources/css/style.min.css?v=4.0.0" rel="stylesheet">
		
		<script src="/swimpool-ssm/back/resources/js/jquery.min.js?v=2.1.4"></script>
		<script src="/swimpool-ssm/back/resources/js/bootstrap.min.js?v=3.3.5"></script>
		<script src="/swimpool-ssm/back/resources/js/content.min.js?v=1.0.0"></script>
		<script src="/swimpool-ssm/back/resources/js/plugins/validate/jquery.validate.min.js"></script>
		<script src="/swimpool-ssm/back/resources/js/plugins/validate/messages_zh.min.js"></script>
		<script type="text/javascript" src="/swimpool-ssm/back/resources/js/contabs.min.js"></script>
		<script src="/swimpool-ssm/back/resources/js/demo/form-validate-demo.min.js"></script>
		<script src="/swimpool-ssm/js/util.js"></script>
	</head>

	<body class="gray-bg">
		<div class="wrapper wrapper-content animated">
			<div class="row">
				<div class="col-sm-11">
					<div class="ibox float-e-margins">
						<div class="ibox-title">
							<h5>Goods Update</h5>
							<div class="ibox-tools">
								<a class="collapse-link">
									<i class="fa fa-chevron-up"></i>
								</a>
								<a class="dropdown-toggle" data-toggle="dropdown"
									href="form_basic.html#"> <i class="fa fa-wrench"></i>
								</a>
							</div>
						</div>
						<div class="ibox-content">
							<form class="form-horizontal m-t" id="form">
								<input type="hidden" id="id" name="id">
								<div class="form-group">
									<label class="col-sm-3 control-label">Name：</label>
									<div class="col-sm-8">
										<input id="name" name="name" minlength="2" type="text"
											class="form-control" required="" aria-required="true">
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">price：</label>
									<div class="col-sm-8">
										<input id="price" type="number" class="form-control"
											name="price" required="" aria-required="true">
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">perLong：</label>
									<div class="col-sm-8">
										<input id="perLong" type="number" class="form-control" name="perLong">
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">weekLong：</label>
									<div class="col-sm-8">
										<input id="weekLong" type="number" class="form-control" name="weekLong">
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">peoNum：</label>
									<div class="col-sm-8">
										<input id="peoNum" type="number" class="form-control" name="peoNum">
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">Type：</label>
									<div class="col-sm-8">
										<select name="souType" id="souType" class="form-control">
											<option value="0">class</option>
											<option value="1">member</option>
											<option value="2">age</option>
										</select>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">status：</label>
									<div class="col-sm-8">
										<select name="status" id="status" class="form-control">
											<option value="1">enable</option>
											<option value="0">disable</option>
										</select>
									</div>
								</div>
								<div class="form-group">
									<div class="col-sm-4 col-sm-offset-3" id="submit">
										<button class="btn btn-primary" type="button" onclick="formSubmit()">submit</button>
									</div>
								</div>
								<div class="form-group">
									<div class="col-sm-4 col-sm-offset-3">
										<span id="info"></span>
									</div>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>
<script type="text/javascript">
	/**
		提交
	*/
	function formSubmit()
	{
		var param = $("#form").serialize();
		
		$.post(
			rootPath + "/class/goodsUpdate.mvc",
			param,
			function(data)
			{
				$("#info").html(data.info);
			},
			"json"
		);
		return false ; 
	}
	
	/* 根据id查询数据 */
	function getDataById(id,operType)
	{
		if(operType == 'update')
		{
			$("#submit").show() ;
		}else
		{
			$("#submit").hide() ;
		}
		
		$.post(
			rootPath + "/class/goodsInfo.mvc",
			"id=" + id,
			function(data)
			{
				console.info("====" + data) ; 
				var dataOne = data.data.one ;
				/* 循环数据 */
				for(var temp in dataOne)
				{
					var tempObj = $("#" + temp) ;
					//console.info(temp + "=====" + tempObj.length + "====" + tempObj.size + "====" + dataOne[temp])
					if(tempObj.length > 0 )
					{
						/* 赋值 */
						tempObj.val(dataOne[temp]);
					}
				}
			},
			"json"
		);
		return false ; 
	}
	
	/* 获取id */
	var id = urlParam("id") ; 
	/* 获取operType */
	var operType = urlParam("operType") ;
	getDataById(id,operType) ;
	console.info("==operType==="+ operType);
</script>